/*
 * Copyright QLH 2023
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.feeyo.groundservice.composewidget.view.util

import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.intl.Locale
import com.feeyo.groundservice.composewidget.R

/**
 * creator:  QLH
 * effect : 资源,文本 颜色 图片....
 * warning:
 */
object Res {

    @Composable
    fun getStarSelectPainter(): Painter =
        painterResource(id = R.drawable.star_bar_star_select)

    @Composable
    fun getStarPainter(): Painter = painterResource(id = R.drawable.star_bar_star)

    //用户指定的语言
    private var Res_language: String? = null

    //获取当前是什么语言
    private fun getLanguage(): String {
        Res_language?.let { return it }
        return Locale.current.language
    }

    /**
     * 手动设置当前的语言
     */
    fun setLanguage(language: String) {
        Res_language = language
    }



    fun getNoMoreDataString(): String {
        return when (getLanguage()) {
            LanguageType.ZH.msg-> "没有更多数据了"
            LanguageType.EN.msg -> "No more data"
            else -> "没有更多数据了"
        }
    }

    fun getLoadingString(): String {
        return when (getLanguage()) {
            LanguageType.ZH.msg -> "正在加载…"
            LanguageType.EN.msg -> "Loading"
            else -> "正在加载…"
        }
    }

    fun getRefreshCompleteString(): String {
        return when (getLanguage()) {
            LanguageType.ZH.msg -> "刷新完成"
            LanguageType.EN.msg -> "Refresh complete"
            else -> "刷新完成"
        }
    }

    fun getRefreshingString(): String {
        return when (getLanguage()) {
            LanguageType.ZH.msg -> "正在刷新…"
            LanguageType.EN.msg -> "Refreshing"
            else -> "正在刷新…"
        }
    }

    fun getDropDownToRefreshString(): String {
        return when (getLanguage()) {
            LanguageType.ZH.msg -> "下拉可以刷新"
            LanguageType.EN.msg -> "Pull to refresh"
            else -> "下拉可以刷新"
        }
    }

    fun getReleaseRefreshNowString(): String {
        return when (getLanguage()) {
            LanguageType.ZH.msg -> "释放立即刷新"
            LanguageType.EN.msg -> "Release refresh"
            else -> "释放立即刷新"
        }
    }

    fun getLastUpdateString(): String {
        return when (getLanguage()) {
            LanguageType.ZH.msg -> "上次更新"
            LanguageType.EN.msg -> "Last update"
            else -> "上次更新"
        }
    }
}
